<template>

  <div>
    <el-form ref="form" :model="business" label-width="80px">
      <el-form-item label="商家类型">
        <el-input v-model="business.typeName" readonly />
      </el-form-item>
      <el-form-item label="商家名称">
        <el-input v-model="business.name" readonly />
      </el-form-item>
      <el-form-item label="法人">
        <el-input v-model="business.corporation" readonly />
      </el-form-item>
      <el-form-item label="省">
        <el-input v-if="business.provinceE != null&&business.provinceE != ''" v-model="business.provinceE.regionName" readonly />
      </el-form-item>
      <el-form-item label="市">
        <el-input v-if="business.cityE != null&&business.cityE != ''" v-model="business.cityE.regionName" readonly />
      </el-form-item>
      <el-form-item label="区">
        <el-input v-if="business.countyE != null&&business.countyE != ''" v-model="business.countyE.regionName" readonly />
      </el-form-item>
      <el-form-item label="详细地址">
        <el-input v-model="business.address" readonly />
      </el-form-item>
      <el-form-item label="状态">
        <el-input v-model="business.statusName" readonly />
      </el-form-item>
      <el-form-item label="管理员">
        <el-input v-model="business.userE.username" readonly />
      </el-form-item>
      <el-form-item label="统一征信码">
        <el-input v-model="business.zheng" readonly />
      </el-form-item>
      <el-form-item label="营业执照">
        <img :src="business.url">
      </el-form-item>
      <el-form-item label="申请时间">
        <el-input v-model="business.createTime" value-format="yyyy-MM-dd HH:mm:ss" readonly />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit(1)">通过</el-button>
        <el-button type="primary" @click="onSubmit(2)">不通过</el-button>
        <el-button type="primary" @click="onSubmit(3)">返回</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>

<script>
export default {
  name: 'Businessreview',
  data() {
    return {
      business: {
        id: '',
        type: '',
        typeName: '',
        name: '',
        corporation: '',
        userE: {
          userId: '',
          username: ''
        },
        provinceE: {
          regionId: '',
          regionName: ''
        },
        cityE: {
          regionId: '',
          regionName: ''
        },
        countyE: {
          regionId: '',
          regionName: ''
        },
        address: '',
        status: '',
        statusName: '',
        url: '',
        zheng: '',
        createTime: ''
      }
    }
  },
  mounted() {
    this.business = []
    this.getData()
  },
  methods: {
    onSubmit(val) {
      this.business.status = val
      // eslint-disable-next-line eqeqeq
      if (val == 1 || val == 2) {
        this.axios.post('http://localhost:9999/wish/sizu/system/business/review', this.business).then((res) => {
          if (res.data.obj) {
            alert(res.data.msg)
            this.$store.dispatch('tagsView/delView', this.$route)
            this.$router.go(-1)
          } else {
            alert(res.data.msg)
          }
        })
      } else {
        this.$store.dispatch('tagsView/delView', this.$route)
        this.$router.go(-1)
      }
    },
    getData() {
      this.business = this.$route.params.business
      // eslint-disable-next-line eqeqeq
      if (this.business.type == 1) {
        this.business.typeName = '公司化公寓'
      }
      // eslint-disable-next-line eqeqeq
      if (this.business.status == 1) {
        this.business.statusName = '审核通过'
      }
      // eslint-disable-next-line eqeqeq
      if (this.business.status == 2) {
        this.business.statusName = '审核不通过'
      }
      // eslint-disable-next-line eqeqeq
      if (this.business.status == 3) {
        this.business.statusName = '待审核'
      }
    }
  }
}
</script>

<style scoped>

</style>
